<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">公告</block>
		</cu-custom>
		<view class="cu-card article" v-for="(item,index) in data" :key="index" @click="handle(item)">
			<view class="cu-item shadow">
				<view class="title">
					<view class="text-cut">{{item.title}}</view>
				</view>
				<view class="content">
					<view class="desc">
						<view class="text-content">这是学校方面下发的关于车辆管理的通知公告，请各位同学点进该公告仔细查阅并且遵守学校新颁布的车辆管理制度！！！</view>
						<view>
							<view class="cu-tag bg-red light sm round">{{item.createdAt}}</view>
							<view class="cu-tag bg-green light sm round">{{item.updatedAt}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
			}
		},
		 onLoad() {
			 this.getData()
			 this.dingwei()
		},
		methods: {
			rTime(date) {
				const json_date = new Date(date).toJSON();
				return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(
					/\.[\d]{3}Z/, '')
			},
			 getData() {
				let that = this
				that.$https.get('/rest/Article').then(res=>{
					that.data = res.data
					that.data = that.data.map(value => {
						value.createdAt = that.rTime(value.createdAt)
						value.updatedAt = that.rTime(value.updatedAt)
						return value
					})
				})
			},
			handle(item) {
				const id = item._id
				uni.navigateTo({ //成功后跳转到小程序首页，由于没得界面，我就屏蔽了。
					url: '/pages/mycenter/reports?id='+id,
					success: function(res) {},
					fail: function(res) {
						console.log(';21123213', res)
					}
				});
			},
			dingwei() {
				uni.getLocation({
					success:function(res) {
						console.log(res,'zhubinzhongyuling')
					},
				})
			}
		},
		// created() {
		// 	this.getData()
		// }
	}
</script>

<style>
</style>
